<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>
<style>
    .box {
        width: 400px;
        height: 400px;
        border: 1px solid #ccc;
        margin: auto;
        padding: 20px;
    }
</style>

<body>
    <div id="app">
        <el-button type="primary" @click="getJokes">获取笑话</el-button>
        <div class="box">
            <p>{{joke}}</p>
        </div>
    </div>
</body>
<script>
    // 接口：获取一条笑话
    // 请求地址：https://autumnfish.cn/api/joke
    // 请求方法：get
    // 请求参数：无
    // 响应内容：随机笑话
    new Vue({
        el: '#app',
        data: {
            joke: ''
        },
        methods: {
            getJokes() {
                axios.get('https://autumnfish.cn/api/joke').then((response) => {
                    this.joke = response.data
                }, (error) => {
                    console.log(error);
                })
            },
        },
    })
</script>


</html>